using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Collections;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

using SumGam.Globals;
using SumGam.Structs;
namespace SumGam
{
    static class Data
    {
        public static void SaveStruct<T>(T datastruct, string path)
        {
            FileStream stream = File.Open(path, FileMode.OpenOrCreate);
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            serializer.Serialize(stream, datastruct);
            stream.Close();
        }
        public static T LoadStruct<T>(string path)
        {
            T ret = default(T);
            if (!File.Exists(path))
                return ret;
            FileStream stream = File.Open(path, FileMode.OpenOrCreate, FileAccess.Read);
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            ret = (T)serializer.Deserialize(stream);
            stream.Close();
            return ret;
        }
    }
}